package com.fjec.market.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fjec.common.protocol.JsonResult;
import com.fjec.common.view.ListItem;
import com.fjec.market.entity.InfoBank;
import com.fjec.market.entity.InfoPcc;
import com.fjec.market.mapper.InfoBankMapper;
import com.fjec.market.service.IInfoBankService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author admin
 * @since 2020-10-30
 */
@Service
public class InfoBankServiceImpl extends ServiceImpl<InfoBankMapper, InfoBank> implements IInfoBankService {

    @Resource
    private InfoBankMapper mapper;

    @Override
    public JsonResult getBankByCityCode(String code, String bankType) {
        List<ListItem> resultList = new ArrayList<>();
        List<Map<String, Object>> entityMapList = mapper.getBankByCityCode(code, bankType);
        for (Map<String, Object> entityMap : entityMapList) {
            resultList.add(new ListItem(MapUtils.getString(entityMap, "BankCode"),
                    MapUtils.getString(entityMap, "BankName")));
        }
        return JsonResult.success()
                .data(resultList)
                .build();
    }
}
